﻿@using TD.Common.Kendo.Mvc5.Grid

@section head{
    <link href="@Url.Content("~/Content/td/td.kendo.grid.css")" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/td/td.kendo.grid.js")"></script>
}

@{
    var filterRow = new TD.Common.Kendo.Mvc5.Grid.Filters.FilterRow(Html);
}

@(Html.Kendo().Grid<TD.CTS.Data.Entities.City>()
    .Init("Grid")
    .Editable()
    .Columns(columns =>
    {
        columns.ButtonsCrud(filterRow);
        columns.Bound(e => e.Name, filterRow).Width("100%").Title("Наименование");
    })
    
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Model(model =>
        {
            model.Id(e => e.Id);
        })
        .Read(read => read.Action("GetCities", "Cities").Data("kendo_grid_getfilters"))
        .Create(create => create.Action("AddCity", "Cities"))
        .Update(update => update.Action("UpdateCity", "Cities"))
        .Destroy(update => update.Action("DeleteCity", "Cities"))
        .Events(events => events.Error("kendo_grid_error_handler"))
     )
     .Events(events => events.Edit("kendo_grid_onrowedit"))

)

<script>
    $(document).ready(function () {
        kendo_grid_init($("#Grid"), true, '@Html.Raw(filterRow.HtmlFilterRow())');
    });

</script>

